//
//  WCFontTextField.m
//  WabbitCode
//
//  Created by William Towe on 1/7/09.
//  Copyright 2009 Revolution Software. All rights reserved.
//

#import "WCFontTextField.h"
#import "WCMacros.h"
#import "WCAppController.h"
#import "WCTextView.h"


@implementation WCFontTextField
- (void)awakeFromNib {
	[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.kWCPrefsEditorBackgroundColorKey" options:NSKeyValueObservingOptionNew context:kWCPrefsEditorBackgroundColorKey];
}

- (void)dealloc {
	[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.kWCPrefsEditorBackgroundColorKey"];
	[super dealloc];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
	if ([(NSString *)context isEqualToString:kWCPrefsEditorBackgroundColorKey]) {
		[self setBackgroundColor:NSUserDefaultsKeyedUnarchivedObjectForKey(kWCPrefsEditorBackgroundColorKey)];
		[self setNeedsDisplay:YES];
	}
	else
		[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
@end
